ctxPath = "/education"
$.getUrlParam = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
};


$("#loginBtn").click(function () {
    //校验
    var customerName = $("#customerName").val();
    var customerPassword = sha256_digest($("#customerPassword").val());
    var redirectUrl = $.getUrlParam('redirect');

    if(null == customerName || "" == customerName){
        alert("手机号不能为空！");
    }

    if(null == customerPassword || "" == customerPassword){
        alert("密码不能为空！");
    }

    $.ajax({
        url: ctxPath + '/wx/api/customer/login',
        type: 'post',
        dataType: 'json',
        data: {customerName: customerName, customerPassword: customerPassword},
        success: function (result) {
            if(result.returnCode == 0) {
                if(null!=redirectUrl){
                    window.location.href = redirectUrl;
                }else {
                    window.location.href = "/education/wx/member.html";
                }
            } else {
                alert(result.returnMsg);
            }
        }
    });
})